//
//  StatusToolbar.swift
//  上海微博
//
//  Created by mac on 16/5/18.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class StatusToolbar : UIView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //MARK--设置私有控件
    //转发
    private let retweededButton = UIButton(cz_title: " 转发",
                                           fontSize: 12,
                                           imageName: "timeline_icon_retweet",
                                           backImageName: "timeline_card_bottom_background")
    //评论
    private let talkButton = UIButton(cz_title: " 评论",
                                           fontSize: 12,
                                           imageName: "timeline_icon_comment",
                                           backImageName: "timeline_card_bottom_background")
    //点赞
    private let likeButton = UIButton(cz_title: " 点赞",
                                           fontSize: 12,
                                           imageName: "timeline_icon_unlike",
                                           backImageName: "timeline_card_bottom_background")
}

///MARK: 设置界面
extension StatusToolbar {
    private func setupUI(){
        //背景颜色和父控件一样
        backgroundColor=superview?.backgroundColor
        
        //添加控件
        addSubview(retweededButton)
        addSubview(talkButton)
        addSubview(likeButton)
        //自动布局
        //每个控件占用的大小一样
        retweededButton.snp_makeConstraints { (make) in
            make.left.equalTo(self)
            make.top.equalTo(self)
            make.bottom.equalTo(self)
        }
        talkButton.snp_makeConstraints { (make) in
            make.left.equalTo(retweededButton.snp_right)
            make.bottom.equalTo(retweededButton)
            make.top.equalTo(retweededButton)
        }
        likeButton.snp_makeConstraints { (make) in
            make.left.equalTo(talkButton.snp_right)
            make.top.equalTo(talkButton)
            make.bottom.equalTo(talkButton)
            
            make.width.equalTo(retweededButton)
            //右侧的参照
            make.right.equalTo(self)
        }
        //分割线
        let sep1 = UIImageView(cz_imageName: "timeline_card_bottom_line")
        let sep2 = UIImageView(cz_imageName: "timeline_card_bottom_line")
        addSubview(sep1)
        addSubview(sep2)
        //分割线自动布局
        sep1.snp_makeConstraints { (make) in
            make.left.equalTo(retweededButton.snp_right)
            make.centerY.equalTo(retweededButton)
        }
        sep2.snp_makeConstraints { (make) in
            make.left.equalTo(talkButton.snp_right)
            make.centerY.equalTo(talkButton)
        }
    }
}